// Account.java
//
// Informatics 102 Spring 2012
// Code Example
//
// This class implements a simple bank account, which is defined by an
// accountID and a balance.  Other interesting things about this account,
// such as who owns it, could be implemented separately in aspects.  For
// example, the ownership of the account is implemented in this example
// as an aspect called AccountOwnership.

public class Account
{
	private int accountID;
	private int balance;
	
	
	public Account(int accountID, int balance)
	{
		this.accountID = accountID;
		this.balance = balance;
	}
	
	
	public int getAccountID()
	{
		return accountID;
	}
	
	
	public int getBalance()
	{
		return balance;
	}
	
	
	public void deposit(int amount)
	{
		balance += amount;
	}
	
	
	public void withdraw(int amount)
	throws InsufficientFundsException
	{
		if (balance < amount)
		{
			throw new InsufficientFundsException();
		}
		else
		{
			balance -= amount;
		}
	}
	
	
	public void transferTo(Account targetAccount, int amount)
	throws InsufficientFundsException
	{
		withdraw(amount);
		targetAccount.deposit(amount);
	}
}
